package com.wlz;

import com.wlz.bean.User;
import com.wlz.config.AppConfig;
import com.wlz.event.NotifyEvent;
import com.wlz.event.NotifyListener;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * wlz
 *
 * http://bat.ke.qq.com
 * 往期视频加群:516212256 暗号:6
 */

public class MainApplication {


    public static void main(String[] args) {
        //配置jvm参数 -Dspring.profiles.active=prod
        //1. 重写PropertyPlaceholderConfigurer#loadProperties
       // ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");

        //2. @profile & @Value
       ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        User user = (User) context.getBean("user");
        System.out.println("user name:" + user.getName());


        //事件监听机制
        ((AnnotationConfigApplicationContext) context).addApplicationListener(new NotifyListener());
        context.publishEvent(new NotifyEvent("wlz","wlz@qq.com","this is the content"));





    }
}
